import sys
import os
try:
    from lxml import etree
except:
    import xml.etree.cElementTree as etree

settingspath = os.path.expanduser(r'~\AppData\Roaming\XBMC\userdata\addon_data\plugin.program.skygo.launcher\settings.xml')
configpath = os.path.expanduser(r'~\AppData\Roaming\XBMC\addons\plugin.program.skygo.launcher\skygo.cfg')

doc = etree.parse(settingspath)

settings_dict = dict([(el.attrib['id'], el) for el in doc.findall('setting')])
settings_order = ['username','password','screen2','hidemousepointer','exitonbackspace','refreshonload']

clear(settingspath)
clear(doc)

foo = open(configpath, 'rt')
for setting_id in settings_order:
    if setting_id in settings_dict:
        el = settings_dict[setting_id]
        foo.write("%s=%s\n" % (el.attrib['id'], el.attrib['value']))
foo.close()